﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TODO_LIST._Default" %>    
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <h2>
        Minha primeira to-do list!
    </h2>
    <p>
        ASP.NET Rules! ..doesn't it?!
    </p>
    <table style="width: 50%;">
        <tr>
            <td>
                Nova tarefa:
            </td>
            <td>
                &nbsp;<asp:TextBox ID="txt_tarefa" runat="server"></asp:TextBox>
            </td>
            <td>
                &nbsp;<asp:Button ID="btn_gravar" runat="server"                    
                    Text="Gravar" onclick="btn_gravar_Click" />
            </td>
        </tr>
    </table>
    <asp:GridView ID="gridLista" runat="server" AutoGenerateColumns="False" 
    DataSourceID="SqlDataSource1" 
         Width="50%" onselectedindexchanged="gridLista_SelectedIndexChanged" 
        AllowSorting="True">
        <AlternatingRowStyle BackColor="#FFFFCC" />
        <Columns>
            <asp:BoundField DataField="TAREFA" HeaderText="TAREFA" 
                SortExpression="TAREFA" />
            <asp:CheckBoxField DataField="FEITA" HeaderText="FEITA" 
                SortExpression="FEITA" />
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PECOPECOConnectionString %>" 
        DeleteCommand="delete from lista_tarefas where tarefa = @ptarefa" 
        SelectCommand="SELECT [TAREFA], [FEITA] FROM [LISTA_TAREFAS]">
        <DeleteParameters>
            <asp:ControlParameter ControlID="txt_tarefa" Name="@ptarefa" 
                PropertyName="Text" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:Button ID="btn_editar" runat="server"                    
                    Text="editar" onclick="btn_editar_Click"/>
            
    <asp:TextBox ID="txt_edit" runat="server" Width="38px"></asp:TextBox>
            
    <asp:Button ID="btn_cancelar" runat="server" Text="cancelar edicao" 
        Visible="False" onclick="btn_cancelar_Click" />
            
    <asp:Button ID="btn_confirmar" runat="server" onclick="btn_confirmar_Click" 
        Text="confirmar edicao" />
            
</asp:Content>
